import Cookies from 'js-cookie'

const TokenKey = 'Admin-Token'
const UserNameKey = 'User-Name-Token'
const UserIdKey = 'User-Id-Token'

export function getToken() {
    return Cookies.get(TokenKey)
}

export function setToken(token) {
    return Cookies.set(TokenKey, token)
}

export function removeToken() {
    return Cookies.remove(TokenKey)
}

export function getUserName() {
    return Cookies.get(UserNameKey)
}

export function setUserName(name) {
    return Cookies.set(UserNameKey, name)
}

export function removeUserName() {
    return Cookies.remove(UserNameKey)
}

export function getUserId() {
    return Cookies.get(UserIdKey)
}

export function setUser(id) {
    return Cookies.set(UserIdKey, id)
}

export function removeUser() {
    return Cookies.remove(UserIdKey)
}

export function getCookie(name) {
    /*
    var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
    if(arr===document.cookie.match(reg))
    return unescape(arr[2]);
    else
    return null;
    */
    return Cookies.get(name);
}
